<?php
$fechade = $_REQUEST['fecini'];
$fechaa = $_REQUEST['fecfin'];
//$nomnotaria = "Nombre de la Notaria";
$nomnotaria = " ";
//$fechade = '01/01/2013';
//$fechaa = '31/01/2013';
?>

            <style type="text/css">
			#logo_emp{
				float:left;
				padding:0px;
				margin:0px;
				margin-top:10px;
				margin-left:10px;
				}
			#fec_actual{
				float:right;
				padding:0px;
				margin:0px;
				margin-top:10px;
				margin-right:10px;
				}	
			</style>
	
<?php 
include('conexion.php');

//$fechade=$_REQUEST['fecini'];
$fechade = $_REQUEST['fecini'];

$tiempo = explode ("/", $fechade);
$desde = $tiempo[2] . "-" . $tiempo[1] . "-" . $tiempo[0];

//$fechaa = $_REQUEST['fecfin'];
$fechaa = $_REQUEST['fecfin'];

$tiempo2 = explode ("/", $fechaa);
$hasta = $tiempo2[2] . "-" . $tiempo2[1] . "-" . $tiempo2[0];

$consulta = mysql_query("SELECT * FROM libros WHERE fecing BETWEEN '$desde' AND '$hasta' order by numlibro asc", $conn) or die(mysql_error());

while($rowkar = mysql_fetch_array($consulta)){

echo "
<table  border='1' cellpadding='0' cellspacing='0' align='left'>
  <tr>
    <td width='80' align='center'>".$rowkar['ano']."-".$rowkar['numlibro']."</td>
    <td width='80' align='center'>".$rowkar['fecing']."</td>
    <td width='250' align='center'>"; 
	if ($rowkar['tipper']=="N"){
		$nom=$rowkar['apepat']." ".$rowkar['apemat']." ".$rowkar['prinom']." ".$rowkar['segnom'];
	$textormat=str_replace("?","'",$nom);
    $textoampermat=str_replace("*","&",$textormat);
	echo strtoupper($textoampermat);
	
		} else{
			
			$textormatx=str_replace("?","'",$rowkar['empresa']);
    $textoampermatx=str_replace("*","&",$textormatx);
	echo strtoupper($textoampermatx);
			}
	 echo"</td>
    <td width='200' align='center'>";
	$sqlss=mysql_query("Select * from tipolibro where idtiplib='".$rowkar['idtiplib']."'", $conn) or die(mysql_error());
	$rowss=mysql_fetch_array($sqlss);
	echo $rowss['destiplib'];
	
	echo"</td>
    <td width='100' align='center'>";
	$sqlssa=mysql_query("Select * from nlibro where idnlibro='".$rowkar['idnlibro']."'", $conn) or die(mysql_error());
	$rowssa=mysql_fetch_array($sqlssa);
	echo $rowssa['desnlibro'];
	
	
	echo"</td>
    <td width='70' align='center'>".$rowkar['folio']."</td>
    <td width='100' align='center'>";
	$sqlssd=mysql_query("Select * from tipofolio where idtipfol='".$rowkar['idtipfol']."'", $conn) or die(mysql_error());
	$rowssd=mysql_fetch_array($sqlssd);
	echo $rowssd['destipfol'];
	
	echo"</td>
    <td width='100' align='center'>".$rowkar['ruc']."</td>
    
  </tr>
</table>";
}
?>
